package com.ex.exporttool;

import com.ex.exporttool.service.ExportService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import java.util.Scanner;

/**
 * @author jack.wu
 */
@MapperScan("com.ex.exporttool.mapper")
@SpringBootApplication
public class ExportToolApplication {

    @Autowired
    private ExportService exportService;

    private static ExportService exportService1;

    @PostConstruct
    public void init() {
        exportService1 = exportService;
    }

    public static void main(String[] args) {
        SpringApplication.run(ExportToolApplication.class, args);

        Scanner sc = new Scanner(System.in);
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println();
            System.out.println("**********************************************");
            System.out.println("****************奖金包导出小工具****************");
            System.out.println("**********************************************");
            System.out.println("请选择");
            System.out.println("输入数字0退出");
            System.out.println("输入数字1导出奖金包测算模板");
            System.out.println("想要更多功能请联系我");
            int step = sc.nextInt();
            switch (step) {
                case 1:
                    System.out.println("请输入日期（比如：2020-06）");
                    String month = scanner.nextLine();
                    System.out.println("开始导出" + month + "的奖金包测算模板");
                    boolean flag = exportService1.exportBonusPackageTemplate(month);
                    if (flag) {
                        System.out.println("导出完成，请您在本机d盘的template文件夹中查看");
                    } else {
                        System.out.println("导出失败，请联系管理员");
                    }

                    break;
                case 0:
                    System.out.println("退出程序，欢迎下次使用");
                    System.exit(0);
                    break;
                default:
                    System.out.println("输入错误，请从新输入");
            }
        }
    }


}
